package com.newtouch.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.newtouch.common.Page;
import com.newtouch.dao.FASUserDao;
import com.newtouch.model.FASUser;
import com.newtouch.service.FASUserService;
import com.newtouch.service.base.impl.BaseServiceImpl;
@Service
public class FASUserServiceImpl extends BaseServiceImpl implements
		FASUserService {
	@Autowired
	private FASUserDao fasuserdao;

	public void addFASUser(FASUser fasuser) {
		fasuserdao.insertModelObject(fasuser);
	}

	public Integer deleteFASUser(String id) {
		return fasuserdao.deleteModelObject(new Long(id));
	}

	public Integer editFASUser(FASUser fasuser) {
		return fasuserdao.updateModelObject(fasuser);
	}

	public FASUser findFASUserById(String id) {
		return fasuserdao.getModelObject(new Long(id));
	}

	public List<FASUser> findFASUsers(Page page) {
		return fasuserdao.selectModelObjectListPage(page);
	}

	public FASUser findFASUserByName(String name) {
		Map<String, String> paraMap=new HashMap<String, String>();
		paraMap.put("userName", name);
		List<FASUser> fasUserList= fasuserdao.selectModelObjectList(paraMap);
		if(null==fasUserList||fasUserList.size()>=2||fasUserList.size()==0){
			return null;
		}
		else{
			return fasUserList.get(0);
		}
	}
}